package run.newbug.pro03.security.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import run.newbug.pro03.util.JwtUtils;

import java.util.HashMap;
import java.util.Map;

@RestController
public class AuthenController {
    @RequestMapping("/login")
    public Map<String,Object> doLogin(String username, String password){
        Map<String,Object> map = new HashMap<>();
        if("DAMN4374".equals(username) && "4374".equals(password)){
            map.put("state", 200);
            map.put("msg", "登录成功！！！");
            Map<String ,Object> claim = new HashMap<>();
            claim.put("username", username);
            map.put("authentication", JwtUtils.generateToken(claim));
            return map;
        }else {
            map.put("state", 201);
            map.put("msg", "登录失败....");
            return map;
        }
    }
}
